<?php
using("Expression_Operator");

/**
 * Wrap the opening and closing symbols around the children expressions
 *
 */
class Expression_Operator_Group extends Expression_Operator {
	
	private $_openGroup;
	
	private $_closeGroup;
	
	public function __construct($operator, array $expressions) {
		parent::__construct($operator, $expressions);
		$this->_openGroup = substr($operator, 0, strpos($operator, " "));
		$this->_closeGroup = substr($operator, strpos($operator, " ") + 1);
	}
	
	public function evaluate() {
		$this->build($this->_openGroup);
		$this->build($this->invokeLeaf(current($this->_children)));
		while (next($this->_children)) {
			$this->build(current($this->_children));
		}
		$this->build($this->_closeGroup);
		return $this->compile();
	}
}
?>